<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>我的用户列表</title>

</head>
<body>
<jsp:include page="/incloud/header.jsp"/>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <jsp:include page="/incloud/sidebar.jsp"/>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">我的关注列表</h2>
            </div>
        </div>
        <section class="no-padding-bottom">

            <div class="list-group myList">
                <ul>
                    <c:forEach items="${pageData.data}" var="userMap">
                        <li class="list-group-item">
                            <a href="javascript:" onclick="userDetail(${userMap.id},${userMap.isSecret})">${userMap.realName}</a>
                            <div style="float: right" class="text-right">
                                <input type="submit" class="btn btn-danger" value="取消关注" onclick="delFocus(${userMap.id})">
                            </div>
                        </li>
                    </c:forEach>
                </ul>
                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="javascript:" onclick="pre()" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach begin="1" end="${pageData.totalPage}" varStatus="i">
                            <li><a href="/user/findFocusPage?currPage=${i.count}">${i.count}</a></li>
                        </c:forEach>
                        <li>
                            <a href="javascript:" aria-label="Next" onclick="next()">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <jsp:include page="/incloud/footer.jsp"/>
    </div>
</div>
<script>

    //上一页
    function pre() {
        if (${pageData.currPage-1<=0}) {
            layer.msg("已经是第一页")
            return;
        }
        location.href = "/user/findFocusPage?currPage=${pageData.currPage-1}"
    }

    //下一页
    function next() {
        if (${pageData.currPage+1>pageData.totalPage}) {
            layer.msg("已经是尾页了")
            return;
        }
        location.href = "/user/findFocusPage?currPage=${pageData.currPage+1}"
    }


    function userDetail(userId,isSecret) {

        if(isSecret == 0){

            layer.msg("该用户私密！");
            return;
        }
        location.href="/user/detail?flag=detail&id="+userId;
    }

    function delFocus(userId) {

        $.post("/user/focus",{"userId":userId},function (res) {

            if(res==0){
                window.location.reload();
            }


        })

    }


</script>

</body>
</html>